package com.zhaopin.callback;

import org.apache.poi.ss.formula.functions.T;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Test {


    public void send(Class clazz, Method method) throws InstantiationException, IllegalAccessException, InvocationTargetException, InterruptedException {
        Thread.sleep(3000L);
        Object o = clazz.newInstance();
        System.out.println("发送调用方法请求");
        method.invoke(o);
    }
}


class CallBack {

    public void callbackMethod() {
        System.out.println("执行回调方法");
    }

}
class Main {

    public static void main(String[] args) {
        Test test = new Test();
        new Thread(() -> {
            try {
                test.send(CallBack.class,CallBack.class.getDeclaredMethod("callbackMethod"));
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
        }).start();

        System.out.println("请求发完了我去干别的事情");
    }



}